import http from "@/api";
import { DictionaryLibrary } from "@/api/interface";

/**
 * @name 字典管理
 */

/**
 * 获取字典分类
 * @returns
 */
export const getDictionaryLibraryTypeApi = (params: DictionaryLibrary.getDictionaryLibraryTypeParams) => {
  return http.post<any>(`dictionarylibrary/system/typelist`, params);
};

/**
 * 获取字典
 * @returns
 */
export const getDictionaryLibraryListApi = (params: DictionaryLibrary.getDictionaryLibraryParams) => {
  return http.post<any>("dictionarylibrary/system/list", params);
};

/**
 * 添加字典
 * @param params
 * @returns
 */
export const addDictionaryLibraryApi = (params: DictionaryLibrary.AddDictionaryLibrary) => {
  return http.post<any>(`dictionarylibrary/system/addDict`, params);
};

/**
 * 编辑字典
 * @param params
 * @returns
 */
export const editDictionaryLibraryApi = (params: DictionaryLibrary.EditDictionaryLibrary) => {
  return http.post<any>(`dictionarylibrary/system/editDict`, params);
};

/**
 * 删除字典
 * @param params
 * @returns
 */
export const deleteDictionaryLibraryApi = (params: DictionaryLibrary.DelDictionaryLibrary) => {
  return http.delete(`dictionarylibrary/system/delDict`, params);
};

/**
 * 添加字典类型
 * @param params
 * @returns
 */
export const addDictionaryLibraryTypeApi = (params: DictionaryLibrary.AddDictionaryLibraryType) => {
  return http.post<any>(`dictionarylibrary/system/addDictType`, params);
};

/**
 * 编辑字典类型
 * @param params
 * @returns
 */
export const editDictionaryLibraryTypeApi = (params: DictionaryLibrary.EditDictionaryLibraryType) => {
  return http.post<any>(`dictionarylibrary/system/editDictType`, params);
};

/**
 * 删除字典类型
 * @param params
 * @returns
 */
export const deleteDictionaryLibraryTypeApi = (params: DictionaryLibrary.DelDictionaryLibraryType) => {
  return http.delete(`dictionarylibrary/system/delDictType`, params);
};

/**
 * 根据字典类型获取字典组
 * @param params
 * @returns
 */
export const getDictByCodeApi = (dictTypeCode: string) => {
  return http.get(`dictionarylibrary/system/dict/${dictTypeCode}`);
};
